/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cbsrs.controller;

import com.cbsrs.model.Colleges;
import com.cbsrs.utils.ConnectionDAO;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

/**
 *
 * @author Arnold
 */

public class CollegeDAO extends ConnectionDAO {
    private static final Logger log = Logger.getLogger(CollegeDAO.class);
    public static List<Colleges> findAll() throws Exception{
        List<Colleges> collegeList = new ArrayList<Colleges>();
        String sql="SELECT * FROM colleges";
        SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
        PreparedStatement preparedStatement = getConnectionObject().prepareStatement(sql);
        log.info(preparedStatement.toString());
        ResultSet rs = preparedStatement.executeQuery();
        Colleges college;
        while (rs.next()) {
            college = new Colleges();
            college.setCollegeDescription(rs.getString("college_description"));
            college.setCollegeName(rs.getString("college_name"));
            college.setCollegeID(rs.getInt("college_id"));
            collegeList.add(college);
        }
        closeConnection(getConnectionObject());
        return collegeList;
    }
}
